import 'package:baselib/utils/image_util.dart';
import 'package:baselib/widgets/comm_app_bar.dart';
import 'package:baselib/widgets/comm_click_widget.dart';
import 'package:baselib/widgets/comm_password_textfield.dart';
import 'package:baselib/widgets/comm_textfield.dart';
import 'package:baselib/widgets/gradient_card_view.dart';
import 'package:baselib/widgets/gradient_text_widget.dart';
import 'package:baselib/widgets/inkwell_button.dart';
import 'package:baselib/widgets/nosize_app_bar.dart';
import 'package:baselib/widgets/simple_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:framelib/widgets/comm_widget_manager.dart';
import 'package:framelib/widgets/main_gradient_button.dart';
import 'package:framelib/widgets/page_widget.dart';
import 'package:get/get.dart';
import 'package:module_business/module_comm/viewmodel/login_email_view_model.dart';
import 'package:module_business/module_comm/viewmodel/register_info_view_model.dart';
import 'package:module_business/module_comm/viewmodel/register_view_model.dart';
/**
 * 注册资料完善主页
 */
class RegisterInfoPage extends GetWidget<RegisterInfoViewModel> {
  @override
  Widget build(BuildContext context) {
    return PageWidget.build(
        builder: (RegisterInfoViewModel model){
          print('------------>model.selectedGenderIndex=${model.selectedGenderIndex}');
          return PageWidget.PageScaffoldWidget(
            isShowBg: true,
            appBar: CommAppBar(
              backgroundColor: ColorUtil.instance.color_transparent,
              titleStr: StringUtil.instance.Register,
            ),
            bottomNavigationBar: Container(
              child: Container(
                margin: EdgeInsets.only(
                  top: PxUtil.instance.px_2,
                  bottom: PxUtil.instance.px_20,
                  left: PxUtil.instance.px_20,
                  right: PxUtil.instance.px_20,
                ),
                child: MainGradientButton(
                  onPressed: ()=>model.toRegisterSelectFavoritePage(),
                  isImg: true,
                  imgPath: DrawableUtil.instance.icon_Continue,
                  imgWidth: PxUtil.instance.px_80,
                ),
              ),
            ),
            body: ListView(
              padding: EdgeInsets.only(
                left: PxUtil.instance.px_15,
                right: PxUtil.instance.px_15,
              ),
              shrinkWrap: true,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    InkWellButton(
                      onPressed: ()=>model.onIconPressed(),
                      child: Container(
                        width: PxUtil.instance.px_88,
                        height: PxUtil.instance.px_88,
                        margin: EdgeInsets.only(
                          top: PxUtil.instance.px_66,
                          bottom: PxUtil.instance.px_66,
                        ),
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                            gradient: LinearGradient(
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter,
                                colors: [
                                  ColorUtil.instance.color_AE2CF1,
                                  ColorUtil.instance.color_7776FF,
                                ]),
                            borderRadius: BorderRadius.circular(PxUtil.instance.px_60)
                        ),
                        child:(model.iconPath??'').isEmpty?
                        ImagesUtil.loadAssetImage(
                            DrawableUtil.instance.icon_register_camera,
                            height: PxUtil.instance.px_32,
                            fit: BoxFit.fitHeight
                        ):
                        CommWidgetManager.buildCicleImagWidget(
                          model.iconPath,
                          placeholder: DrawableUtil.instance.icon_register_camera,
                          width: PxUtil.instance.px_88,
                          height: PxUtil.instance.px_88,
                          roundRadius: PxUtil.instance.px_44,
                          backgroundColor: ColorUtil.instance.color_f2f2f2,
                          padding: EdgeInsets.only(),
                          margin: EdgeInsets.only(),
                        ),
                      ),
                    ),
                  ],
                ),
                _buildBarTitle(title: StringUtil.instance.Input_your_nick_name),
                //nick name
                GradientCardView(
                    margin: EdgeInsets.only(
                      top: PxUtil.instance.px_8,
                    ),
                    padding: EdgeInsets.only(
                      left: PxUtil.instance.px_15,
                      right: PxUtil.instance.px_15,
                    ),
                    height: PxUtil.instance.px_43,
                    backGroundColor: ColorUtil.instance.color_2F3F71,
                    child: Row(
                      children: [
                        Expanded(child: CommTextField(
                          defaultUnderlineColor: ColorUtil.instance.color_transparent,
                          foucosUnderlineColor: ColorUtil.instance.color_transparent,
                          lableText: StringUtil.instance.Input_your_nick_name,
                          lableTextStyle: TextStyle(
                              fontSize: PxUtil.instance.px_14,
                              color: ColorUtil.instance.color_d8d8d8),
                          textStyle: TextStyle(fontSize: PxUtil.instance.px_14,color: ColorUtil.instance.color_white),
                          paddingBottm: PxUtil.instance.px_4,
                          // inputFormatters: [WhitelistingTextInputFormatter(RegExp("[0-9a-zA-Z._@]"))],
                          // keyboardType: TextInputType.phone,
                          isShowDeleteMain: true,
                          maxLength: 20,
                          maxLines: 1,
                          defaultCont: model?.nickName??'',
                          textInputAction: TextInputAction.next,
                          onChanged: (value)=>model?.inputChanged(value,0),
                        ))
                      ],
                    )
                ),
                SizedBox(height: PxUtil.instance.px_20,),
                //Date of Birth
                _buildBarTitle(title: StringUtil.instance.Date_of_Birth),
                GradientCardView(
                    margin: EdgeInsets.only(
                      top: PxUtil.instance.px_8,
                    ),
                    height: PxUtil.instance.px_43,
                    backGroundColor: ColorUtil.instance.color_2F3F71,
                    child: CommClickWidget(
                      itemBoxDecoration: BoxDecoration(),
                      title: StringUtil.instance.Select,
                      titleSize: PxUtil.instance.px_14,
                      titlecColor: ColorUtil.instance.color_999999,
                      cont: model.birth,
                      contColor: ColorUtil.instance.color_white,
                      onItemClick: ()=>model.onBirthPressed(),
                    )
                ),
                //Country
                SizedBox(height: PxUtil.instance.px_20,),
                //Date of Birth
                _buildBarTitle(title: StringUtil.instance.Country),
                GradientCardView(
                    margin: EdgeInsets.only(
                      top: PxUtil.instance.px_8,
                    ),
                    height: PxUtil.instance.px_43,
                    backGroundColor: ColorUtil.instance.color_2F3F71,
                    child: CommClickWidget(
                      itemBoxDecoration: BoxDecoration(),
                      title: StringUtil.instance.Select,
                      titleSize: PxUtil.instance.px_14,
                      titlecColor: ColorUtil.instance.color_999999,
                      cont: model.countryId,
                      contColor: ColorUtil.instance.color_white,
                      onItemClick: ()=>model.onCountryPressed(),
                    )
                ),
                SizedBox(height: PxUtil.instance.px_20,),
                //Gender
                _buildBarTitle(title: StringUtil.instance.Gender),
                SizedBox(height: PxUtil.instance.px_12,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    InkWellButton(
                      onPressed: ()=>model.onGenderItemPressed(0),
                      child: Container(
                        width: PxUtil.instance.screenWidth/3,
                        height: PxUtil.instance.screenWidth*125/(3*143),
                        decoration: BoxDecoration(
                          gradient:
                          (model.selectedGenderIndex==0?
                          LinearGradient(colors: [
                            ColorUtil.instance.color_5808FB,
                            ColorUtil.instance.color_9929EA,
                          ]):
                          LinearGradient(colors: [
                            ColorUtil.instance.color_4f5808FB,
                            ColorUtil.instance.color_4f9929EA,
                          ])),
                          border: Border(),
                          borderRadius: BorderRadius.circular(
                              PxUtil.instance.px_8),
                        ),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            ImagesUtil.loadAssetImage(
                                (model.selectedGenderIndex==0?
                                DrawableUtil.instance.icon_selected_Male:
                                DrawableUtil.instance.icon_unselected_Male),
                                width: PxUtil.instance.px_35
                            ),
                            Container(
                              margin: EdgeInsets.only(
                                  top: PxUtil.instance.px_8
                              ),
                              child: Text(
                                StringUtil.instance.Male,
                                style: TextStyle(
                                    color: ColorUtil.instance.color_white,
                                    fontSize: PxUtil.instance.px_12,
                                    fontWeight: FontWeight.bold
                                ),
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                    InkWellButton(
                      onPressed: ()=>model.onGenderItemPressed(1),
                      child: Container(
                        width: PxUtil.instance.screenWidth/3,
                        height: PxUtil.instance.screenWidth*125/(3*143),
                        decoration: BoxDecoration(
                          gradient:
                          (model.selectedGenderIndex==1?
                          LinearGradient(colors: [
                            ColorUtil.instance.color_5808FB,
                            ColorUtil.instance.color_9929EA,
                          ]):
                          LinearGradient(colors: [
                            ColorUtil.instance.color_4f5808FB,
                            ColorUtil.instance.color_4f9929EA,
                          ])),
                          border: Border(),
                          borderRadius: BorderRadius.circular(
                              PxUtil.instance.px_8),
                        ),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            ImagesUtil.loadAssetImage(
                                (model.selectedGenderIndex==1?
                                DrawableUtil.instance.icon_selected_Famale:
                                DrawableUtil.instance.icon_unselected_Famale),
                                width: PxUtil.instance.px_35
                            ),
                            Container(
                              margin: EdgeInsets.only(
                                  top: PxUtil.instance.px_8
                              ),
                              child: Text(
                                StringUtil.instance.Female,
                                style: TextStyle(
                                    color: ColorUtil.instance.color_white,
                                    fontSize: PxUtil.instance.px_12,
                                    fontWeight: FontWeight.bold
                                ),
                              ),
                            )
                          ],
                        ),
                      ),
                    )
                  ],
                ),

              ],
            )
            // SingleChildScrollView(
            //     child: Container(
            //       width: PxUtil.instance.screenWidth,
            //       height: PxUtil.instance.screenHeight-PxUtil.instance.statusBarHeight
            //           -PxUtil.instance.appBarHeight,
            //       padding: EdgeInsets.only(
            //         left: PxUtil.instance.px_15,
            //         right: PxUtil.instance.px_15,
            //       ),
            //       child: _buildMiddleContUi(model),
            //     )
            // ),
          );
        }
    );
  }

  _buildMiddleContUi(RegisterInfoViewModel model) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [

      ],
    );
  }

  _buildBarTitle({String title}){
    return Container(
      width: PxUtil.instance.screenWidth,
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.only(
          left: PxUtil.instance.px_5
      ),
      child: Row(
        children: [
          Container(
            width: PxUtil.instance.px_3,
            height: PxUtil.instance.px_11,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(PxUtil.instance.px_2),
                gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [
                      ColorUtil.instance.color_AE2CF1,
                      ColorUtil.instance.color_7776FF,
                    ]
                )
            ),
          ),
          SizedBox(width: PxUtil.instance.px_8,),
          GradientTextWidget(
            txt: title??'',
          )
        ],
      ),
    );
  }
}
